#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL lcm(LL a,LL b,LL c){
    LL t1=__gcd(a,b);
    LL k1=a/t1*b;
    LL t2=__gcd(k1,c);

    return k1/t2*c;
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n,k;cin>>n>>k;
    for(LL i=1;i<=k-3;i++){
        cout<<1<<" ";
        n--;
    }
    LL f1=n/2;
    LL f2=n/2-1;
    //if( (f&1)&&f!=1) f-=1;
    LL n1=n-f1;
    LL n2=n-f2;
    ///debug(f);debug(n);
    LL a1=1;LL b1=n1-a1;
    LL a2=2;LL b2=n1-a2;
    LL a3=1;LL b3=n2-a3;
    LL a4=2;LL b4=n2-a4;
   // debug(a2);debug(b2);debug(f1);

    if((a1+b1+f1==n)&&lcm(a1,b1,f1)<=n/2){

        cout<<a1<<" "<<b1<<" "<<f1<<"\n";
    }
    else if((a2+b2+f1==n)&&lcm(a2,b2,f1)<=n/2){

        cout<<a2<<" "<<b2<<" "<<f1<<"\n";
    }
    else if((a3+b3+f1==n)&&lcm(a3,b3,f1)<=n/2){

        cout<<a3<<" "<<b3<<" "<<f1<<"\n";
    }
    else if((a4+b4+f2==n)&&lcm(a4,b4,f2)<=n/2){
        cout<<a4<<" "<<b4<<" "<<f2<<"\n";
    }
    else if(f1*2==n&&(lcm(f1/2,f1/2,f1))<=n/2){
        cout<<f1/2<<" "<<f1/2<<" "<<f1<<"\n";
    }
    else if(f2*2==n&&(lcm(f2/2,f2/2,f2))<=n/2){
        cout<<f2/2<<" "<<f2/2<<" "<<f2<<"\n";
    }
  }
return 0;
}
